// 字符串截取
export const character = (str) => {
  if (str.length < 20) return str;
  return str.substring(0, 20) + '...';
};
// 数据类型判断
export function typeOf(value) {
  return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
}
// 手机号脱敏
export function hideMobile(mobile) {
  return mobile.replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2');
}
// 格式化金额
export function formattMoney(amount, code = true) {
  const obj = {
    minimumFractionDigits: 2,
    maximumFractionDigits: 2,
  };
  if (code) {
    obj.style = 'currency';
    obj.currency = 'CNY';
  }
  return Number(amount).toLocaleString('zh-CN', obj);
}
